package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum DateType {

    ALL(0,"全时段"),
    DATE(1,"日期"),
    WEEK(2,"周"),
    MONTH(3,"月度"),
    SEASON(4,"季度"),
    HALF_YEAR(5,"半年"),
    YEAR(6,"年度"),
    SELF(7,"自定义"),
    ;

    @JsonValue
    private Integer value;
    private String description;

    private static final Map<Integer, DateType> VALUES = new HashMap<>();

    static {
        for (final DateType dateType : DateType.values()) {
            DateType.VALUES.put(dateType.getValue(), dateType);
        }
    }

    @JsonCreator
    public static DateType getByValue(Integer value) {
        return DateType.VALUES.get(value);
    }
}
